package com.emip.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.emip.bean.PlanBean;
import com.emip.dao.BaseDAO;
import com.emip.dao.PlanDAO;


@Repository("planDAO")
public class PlanDAOImpl extends BaseDAO implements PlanDAO {

	public PlanBean merge(PlanBean plan) {
		return getHibernateTemplate().merge(plan);
	}

	public List<PlanBean> findByTime(String startDate, String endDate,
			String siteId, int page, int size) {
		String hql = "from PlanBean p where p.createTime >= " 
					+ " to_date(" + startDate + ", 'yyyy-mm-dd') and "
					+ "p.createTime <= to_date(" + endDate + ", 'yyyy-mm-dd')";
		if (siteId != null) {
			hql += " and siteId = " + siteId;
		}
		return getEntities(PlanBean.class, hql, page, size);
	}

}
